#pragma once
#include <opencv4/opencv2/opencv.hpp>
#include "FrameProperty.hpp"
#include<chrono>
namespace Moduels::FramesIO{
    class VideoRecorder {
    protected:
        cv::VideoWriter VideoBuilder;
        std::string VideoPath;
        cv::Size VideoSize;
        FrameProperty Format;
        int Index=0;
        std::chrono::steady_clock::time_point LastTime;
    public:

        std::string CreateFilePath(std::string path);

        VideoRecorder(FrameProperty format) :Format(format)
        {
            // 定义存储路径
            VideoPath= format.Root + "/video";
            VideoSize=Format.FrameSize;
            Init();
        }
        ~VideoRecorder()
        {
            VideoBuilder.release();
        }
        /**
         * @brief 创建存储目录，开启视频存储流
         */
        void Init();
        /**
         * @brief 添加图片到视频流
         * @param frame
         */
        void AddFrameToVideo(cv::Mat frame);

        /**
         * @brief 保存当前视频并且创建新的视频流
         */
        void Save2New();

    };
}




